/*2、题目：编写程序，模拟银行账户功能。要求具有的属性包括：账号、储户姓名、地址、存款余额、最小余额；
具有的方法包括：存款、取款、査询。根据用户操作显示储户相关信息。如存款操作后，显示储户原有余额、
今日存款数额及最终存款余额；取款时，若最后余额小于最小余额，拒绝取款，并显示“至少保留余额 XXX ”。
 */

package demo;
import java.util.Scanner;
class BankAccount{
    private String account;//账户
    private String name,address;//姓名 地址
    private double money;//账户余额
    private double minmoney=100;//最小余额
    private int daymoney=0;

    public void setAccount(String account) {
        this.account = account;
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setAddress(String address) {
        this.address = address;
    }
     //设置最小余额
    public void setMinmoney(double minmoney) {
        this.minmoney = minmoney;
    }

    public  BankAccount(String  account, String name, String address) {
        this.account = account;
        this.name = name;
        this.address = address;
    }
    //显示账户信息
    public void show(){
        System.out.println("您的账户信息：");
        System.out.println("账户："+account);
        System.out.println("姓名："+name);
        System.out.println("地址："+address);
    }
    //存款
    public void saveMoney(int savemoney){
        System.out.println("账户余额："+money);
        System.out.println("存款数："+savemoney);
        money+=savemoney;
        daymoney+=savemoney;
        System.out.println("存款成功！");
        System.out.println("账户余额："+money);
        System.out.println("今日存款数："+daymoney);
    }
    //取款
    public void getMoney(int getmoney){
        System.out.println("账户余额："+money);
        System.out.println("取款数："+getmoney);

        if(money-getmoney<minmoney){
            System.out.println("拒绝取款！");
            System.out.println("请至少保留："+minmoney);
        }else{
            money-=getmoney;
            System.out.println("取款成功！");
            System.out.println("账户余额"+money);
        }

    }
    public void getInformation(){
        System.out.println("您的账户信息：");
        System.out.println("账户："+account);
        System.out.println("姓名："+name);
        System.out.println("地址："+address);
        System.out.println("账户余额："+ money);
    }
}
public class Test{
    public static void main(String[] args) {

        Scanner sc=new Scanner(System.in);
        BankAccount bank=new  BankAccount("1001","张三","XX大学校区");
        bank.show();

        do{
            System.out.println("请输入您需要进行的操作：");
            System.out.println("1.存款");
            System.out.println("2.取款");
            System.out.println("3.查询");
            int a= sc.nextInt();
            if(a==1){ //存款
                System.out.println("请输入存款金额：");
                bank.saveMoney(sc.nextInt());

            }
            else if(a==2){  //取款
                System.out.println("请输入取款金额：");
                bank.getMoney(sc.nextInt());

            }
            else if(a==3){ //查询
                bank.getInformation();
            }else{
                System.out.println("输入错误！");
            };
            //是否进行下一步
            System.out.println("1.菜单 2.退出");
            int b= sc.nextInt();
            if(b==1){
                continue;
            }
            else if(b==2){
                break;
            }
            else{
                System.out.println("输入错误！");
            }
         }while(true);

    }
}